package com.mengshu.token.properties;

import com.mengshu.token.utils.TimeUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * <p>
 *     Token配置
 * </p>
 *
 * @author liuning
 * @date 4:28 下午 2022/2/13
 */
@Getter
@Setter
@NoArgsConstructor
public class TokenConfig {
    // token存储前缀
    private String prefix;
    // 排除指定路径
    private String excludes;
    // 登录失效时间 默认30分钟 例如 5s 五秒，6m 六分钟，7h 七小时，8d 八天
    private String timeout = "30m";
    // 登录失效时间 单位s
    private long longTimeout = TimeUtils.getSeconds(timeout);

    public void setTimeout(String timeout) {
        this.timeout = timeout;
        this.longTimeout = TimeUtils.getSeconds(timeout);
    }

    public TokenConfig(String prefix, String excludes, String timeout) {
        this.prefix = prefix;
        this.excludes = excludes;
        this.timeout = timeout;
        this.longTimeout = TimeUtils.getSeconds(timeout);
    }
}
